open(BUFF,"/data1/bsi/BORA_processing/devel/data_HTHGU/NormSumSrc/Agilent_V1/bin/AgilentG4502A_07_3.adf") or die "no adf file exists\n";
$line=<BUFF>;
while(<BUFF>)
{
	chomp($_);
	@array = split(/\t/,$_);
	@entrez_ids = split(',',$array[8]);
	if($array[9] !~ m/-/)
	{
		#print "$array[@array-2]\n";
		$array[9] = $array[7];
	}
	#if($. == 57261)
	#{
	#	print "$array[9]\n";
	#}
	@coords =split(',',$array[9]);
	for($i=0;$i<@coords;$i++)
	{
		#print $entrez_ids[$i]."\n";
		@entid = split(/\|/,$entrez_ids[$i]);	
		#$entrez_ids[$i] =~ s/^\w+\|//g;
		#print  $entrez_ids[$i]."\n";	
		#print $coords[$i]."\n";
		@ind = split(':',$coords[$i]);
		@pos = split('-',$ind[2]);
		#print "$ind[1]\t$pos[0]\t$pos[1]\n";
		$ind[1] =~ s/X/23/g;
		$ind[1] =~ s/Y/24/g;
		$ind[1] =~ s/ //g;
		chomp($entid[1]);
		if($ind[1] ne "" && $pos[0] ne "" && $pos[1] ne "")
		{
			#if($entid[1] eq "646609")
			#{
			#	print "$entid[1]\t$ind[1]\t$pos[0]\t$pos[1]\n";
			#}
			$hash{$entid[1]} = "$entid[1]\t$ind[1]\t$pos[0]\t$pos[1]";	
		}
	}
}
open(BUFF,"GE.txt") or die "no GE file found\n";
$line =<BUFF>;
open(WRBUFF,">geneloc.txt");
print WRBUFF "geneid\tchrm_probe\ts1\ts2\n";
while(<BUFF>)
{
        chomp($_);
	@array = split(/\t/,$_);
	if(exists($hash{$array[0]}))
	{
		print WRBUFF $hash{$array[0]}."\n";
	}
	else
	{
		die "$array[0]\n";
	}
}

